private ["_var","_params","_player_id","_rights","_grant","_idx","_right"];
_var = _this select 0;
_params = _this select 1;

if (toupper(_var) == "MSO_R_GRANTRIGHT") then {
	_player_id = _params select 0;
	_grant = _params select 1;
	_rights = _params select 2;
	if (typename _rights == typename "") then {
		_rights = [_rights];
	};
	if (typename _rights == typename []) then {
		if ((getPlayerUID(player) == _player_id)
			|| (str(player) ==  _player_id)
			|| (name player == _player_id)) then {
			
			if (!_grant && (_rights select 0) == "__REMOVE_LOCAL_RIGHTS__") then {
				MSO_R_Locals = [];
			};
			{
				_right = toLower(_x);
				if (_right != "") then {
					_idx = MSO_R_Locals find _right;
					if (_idx >= 0) then {
						if (!_grant) then { MSO_R_Locals set [_idx, "XxDelxX"] };
					} else {
						if (_grant) then { MSO_R_Locals set [count MSO_R_Locals, _right] };
					};
				};
			} foreach _rights;
			MSO_R_Locals = MSO_R_Locals - ["XxDelxX"];
		};
	};
};